<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>保存文件(File saving)</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GDK-PixBuf 库参考手册">
<link rel="up" href="rn01.html" title="API 参考">
<link rel="prev" href="gdk-pixbuf-file-loading.html" title="加载文件(File Loading)">
<link rel="next" href="gdk-pixbuf-creating.html" title="内存中的图象数据(Image Data in Memory)">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk-pixbuf-file-loading.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="rn01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK-PixBuf 库参考手册</th>
<td><a accesskey="n" href="gdk-pixbuf-creating.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk-pixbuf-file-saving.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gdk-pixbuf-file-saving.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gdk-pixbuf-file-saving"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk-pixbuf-file-saving.top_of_page"></a>保存文件(File saving)</span></h2>
<p>保存文件(File saving) — 保存一个 pixbuf 到文件。</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gdk-pixbuf-file-saving.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gdk-pixbuf/gdk-pixbuf.h&gt;

#define             <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-savev" title="gdk_pixbuf_savev">gdk_pixbuf_savev</a>
#define             <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save" title="gdk_pixbuf_save">gdk_pixbuf_save</a>
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            (<a class="link" href="gdk-pixbuf-file-saving.html#GdkPixbufSaveFunc" title="GdkPixbufSaveFunc ()">*GdkPixbufSaveFunc</a>)                (<em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buf</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> count</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-callback" title="gdk_pixbuf_save_to_callback ()">gdk_pixbuf_save_to_callback</a>         (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-file-saving.html#GdkPixbufSaveFunc" title="GdkPixbufSaveFunc ()"><span class="type">GdkPixbufSaveFunc</span></a> save_func</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-callbackv" title="gdk_pixbuf_save_to_callbackv ()">gdk_pixbuf_save_to_callbackv</a>        (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-file-saving.html#GdkPixbufSaveFunc" title="GdkPixbufSaveFunc ()"><span class="type">GdkPixbufSaveFunc</span></a> save_func</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> **option_keys</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> **option_values</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-buffer" title="gdk_pixbuf_save_to_buffer ()">gdk_pixbuf_save_to_buffer</a>           (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> **buffer</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *buffer_size</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-bufferv" title="gdk_pixbuf_save_to_bufferv ()">gdk_pixbuf_save_to_bufferv</a>          (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> **buffer</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *buffer_size</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> **option_keys</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> **option_values</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-stream" title="gdk_pixbuf_save_to_stream ()">gdk_pixbuf_save_to_stream</a>           (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a href="../gio/GOutputStream.html"><span class="type">GOutputStream</span></a> *stream</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><a href="../gio/GCancellable.html"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-file-saving.description"></a><h2>Description</h2>
<p>
这个函数允许以多种文件格式保存一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> 。格式化的数据可以
被写进一个文件或内存缓冲区。<span class="application">gdk-pixbuf</span> 也可以对该数据调用一个用户定义的
回调函数，例如将图像写进套接字或将其储存到数据库。
</p>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-file-saving.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="gdk-pixbuf-savev"></a><h3>gdk_pixbuf_savev</h3>
<pre class="programlisting">#define gdk_pixbuf_savev gdk_pixbuf_savev_utf8
</pre>
<p>
以 <em class="parameter"><code>type</code></em> 格式保存 pixbuf 到文件，当前的格式有 "jpeg", "png|
$_1_$|, "tiff", "ico" or "bmp"。如果 
<em class="parameter"><code>error</code></em> 被设置，则返回 <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>。参见<a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save" title="gdk_pixbuf_save"><code class="function">gdk_pixbuf_save()</code></a> 以获取更多信息。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
<td>要保存的文件名。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>文件的格式</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>option_keys</code></em> :</span></p></td>
<td>要设置的选项的名称，以 <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> 结束。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>option_values</code></em> :</span></p></td>
<td>名字选项的值</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>return location for error, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>错误是否已经被设置</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-save"></a><h3>gdk_pixbuf_save</h3>
<pre class="programlisting">#define gdk_pixbuf_save gdk_pixbuf_save_utf8
</pre>
<p>
以 <em class="parameter"><code>type</code></em> 格式保存 pixbuf 到文件。省缺情况下，"jpeg", "png|
$_1_$|, "ico" and "bmp" 可用作保存格式，但可以安装更
多的格式。所有的可写格式可以用一下方法得到：
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
void add_if_writable (GdkPixbufFormat *data, GSList **list)
{
  if (gdk_pixbuf_format_is_writable (data))
    *list = g_slist_prepend (*list, data);
}

GSList *formats = gdk_pixbuf_get_formats ();
GSList *writable_formats = NULL;
g_slist_foreach (formats, add_if_writable, &amp;writable_formats);
g_slist_free (formats);
</pre></div>
<p>
</p>
<p>
如果 <em class="parameter"><code>error</code></em> 被设置，则返回 <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> 。可能的错误为 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GDK-PIXBUF-ERROR:CAPS" title="GDK_PIXBUF_ERROR"><span class="type">GDK_PIXBUF_ERROR</span></a> 或 
<a href="../glib/glib-File-Utilities.html#G-FILE-ERROR:CAPS"><span class="type">G_FILE_ERROR</span></a>。
</p>
<p>
变量列表应该以 <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> 结束；如果不空，应该包含改变保存参数的字符串对。例如：
</p>
<div class="informalexample"><pre class="programlisting">
gdk_pixbuf_save (pixbuf, handle, "jpeg", &amp;error,
                 "quality", "100", NULL);
</pre></div>
<p>
</p>
<p>
当前只有几个参数。保存JPEG图像时可以使用 "quality" 参数，其值应该
在 [0,100] 范围内。
</p>
<p>
通过指定 "tEXt::key" 参数，可以给PNG图像附加文本信息，其中 key 应
该为1-79字符长度的ASCII字符，值应该是UTF-8编码的字符串。可以通过 "
compression" 参数指定PNG图像的压缩级别，其值应该是 [0,9] 范围的整数。
</p>
<p>
ICC color profiles can also be embedded into PNG and TIFF images.
The "icc-profile" value should be the complete ICC profile encoded
into base64.
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
gchar *contents;
gchar *contents_encode;
gsize length;
g_file_get_contents ("/home/hughsie/.color/icc/L225W.icm", &amp;contents, &amp;length, NULL);
contents_encode = g_base64_encode ((const guchar *) contents, length);
gdk_pixbuf_save (pixbuf, handle, "png", &amp;error,
                 "icc-profile", contents_encode,
                 NULL);
</pre></div>
<p>
</p>
<p>
TIFF images recognize a "compression" option which acceps an integer value.
Among the codecs are 1 None, 2 Huffman, 5 LZW, 7 JPEG and 8 Deflate, see
the libtiff documentation and tiff.h for all supported codec values.
</p>
<p>
ICO 图像可以通过使用 "depth" 参数指定以16，24或32(位)色深保存。当
保存 ICO 时给定了 "x_hot" 和 "y_hot" 参数，则生成一
个 CUR 来取代 ICO.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
<td>要保存的文件名。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>文件的格式</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>return location for error, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>保存选项的键-值对(key-value)的列表(list)。</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>错误是否已经被设置</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GdkPixbufSaveFunc"></a><h3>GdkPixbufSaveFunc ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            (*GdkPixbufSaveFunc)                (<em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buf</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> count</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>
指定传递到 <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-callback" title="gdk_pixbuf_save_to_callback ()"><code class="function">gdk_pixbuf_save_to_callback()</code></a> 的函数类型。它在
 <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-callback" title="gdk_pixbuf_save_to_callback ()"><code class="function">gdk_pixbuf_save_to_callback()</code></a> 写每一块数据的时候被调用。如果成功返回
 <a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>。如果有错误发生，<em class="parameter"><code>error</code></em> 将被设置且返回 <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>，这种情况下，
 <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-callback" title="gdk_pixbuf_save_to_callback ()"><code class="function">gdk_pixbuf_save_to_callback()</code></a> 将发生同样的错误。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>buf</code></em> :</span></p></td>
<td>bytes to be written.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>count</code></em> :</span></p></td>
<td>number of bytes in <em class="parameter"><code>buf</code></em>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>A location to return an error.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>user data passed to <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-callback" title="gdk_pixbuf_save_to_callback ()"><code class="function">gdk_pixbuf_save_to_callback()</code></a>.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if successful, <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> (with <em class="parameter"><code>error</code></em> set) if failed.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-save-to-callback"></a><h3>gdk_pixbuf_save_to_callback ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            gdk_pixbuf_save_to_callback         (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-file-saving.html#GdkPixbufSaveFunc" title="GdkPixbufSaveFunc ()"><span class="type">GdkPixbufSaveFunc</span></a> save_func</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
按 <em class="parameter"><code>type</code></em> 格式保存 pixbuf 到一个回调函数，通过将产生的数据传递个该回调函数的方
式。可以用来当你想把图像储存在非文件形式的时候，比如一个内存中的缓冲区或者一
个套接字。如果 <em class="parameter"><code>error</code></em> 被设置，则返回 <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>。可能的错误为 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GDK-PIXBUF-ERROR:CAPS" title="GDK_PIXBUF_ERROR"><span class="type">GDK_PIXBUF_ERROR</span></a> 
或者该保存函数(译者注: <em class="parameter"><code>save_func</code></em>)产生的任何错误。
</p>
<p>
请看 <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save" title="gdk_pixbuf_save"><code class="function">gdk_pixbuf_save()</code></a> 以获取更多信息。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>save_func</code></em> :</span></p></td>
<td>a function that is called to save each block of data that
the save routine generates. <span class="annotation">[<acronym title="The callback is valid only during the call to the method."><span class="acronym">scope call</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>传递给保存函数(译者注: <em class="parameter"><code>save_func</code></em>)的用户数据。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>文件的格式</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>return location for error, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>保存选项的键-值对(key-value)的列表(list)。</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>错误是否已经被设置</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-save-to-callbackv"></a><h3>gdk_pixbuf_save_to_callbackv ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            gdk_pixbuf_save_to_callbackv        (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-file-saving.html#GdkPixbufSaveFunc" title="GdkPixbufSaveFunc ()"><span class="type">GdkPixbufSaveFunc</span></a> save_func</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> **option_keys</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> **option_values</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
按 <em class="parameter"><code>type</code></em> 格式保存 pixbuf 到一个回调函数，当前的格式有 "jpeg", |
$_1_$|png", "tiff", "ico" or "bmp|$_1_
$|。如果 <em class="parameter"><code>error</code></em> 被设置，则返回 <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>。参见<a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-callback" title="gdk_pixbuf_save_to_callback ()"><code class="function">gdk_pixbuf_save_to_callback()</code></a> 以获
取更多信息。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>save_func</code></em> :</span></p></td>
<td>a function that is called to save each block of data that
the save routine generates. <span class="annotation">[<acronym title="The callback is valid only during the call to the method."><span class="acronym">scope call</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>传递给保存函数(译者注: <em class="parameter"><code>save_func</code></em>)的用户数据。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>文件的格式</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>option_keys</code></em> :</span></p></td>
<td>要设置的选项的名称，以 <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> 结束。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>option_values</code></em> :</span></p></td>
<td>名字选项的值</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>return location for error, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>错误是否已经被设置</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-save-to-buffer"></a><h3>gdk_pixbuf_save_to_buffer ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            gdk_pixbuf_save_to_buffer           (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> **buffer</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *buffer_size</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Saves pixbuf to a new buffer in format <em class="parameter"><code>type</code></em>, which is currently "jpeg",
"png", "tiff", "ico" or "bmp".  This is a convenience function that uses
<a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-callback" title="gdk_pixbuf_save_to_callback ()"><code class="function">gdk_pixbuf_save_to_callback()</code></a> to do the real work. Note that the buffer 
is not nul-terminated and may contain embedded  nuls.
If <em class="parameter"><code>error</code></em> is set, <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> will be returned and <em class="parameter"><code>buffer</code></em> will be set to
<a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. Possible errors include those in the <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GDK-PIXBUF-ERROR:CAPS" title="GDK_PIXBUF_ERROR"><span class="type">GDK_PIXBUF_ERROR</span></a>
domain.
</p>
<p>
请看 <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save" title="gdk_pixbuf_save"><code class="function">gdk_pixbuf_save()</code></a> 以获取更多信息。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td>
<td>接收这个新的缓冲区的指针的地址。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>buffer_size</code></em> :</span></p></td>
<td>接收这个新的缓冲区的大小的地址。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>文件的格式</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>return location for error, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>保存选项的键-值对(key-value)的列表(list)。</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>错误是否已经被设置</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-save-to-bufferv"></a><h3>gdk_pixbuf_save_to_bufferv ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            gdk_pixbuf_save_to_bufferv          (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> **buffer</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> *buffer_size</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> **option_keys</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> **option_values</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
按 <em class="parameter"><code>type</code></em> 格式将 pixbuf 储存到一个新的缓冲区，当时的格式有 "jpeg|$_1_
$|, "tiff", "png", "ico" or "bmp|
$_1_$|。参见 <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-buffer" title="gdk_pixbuf_save_to_buffer ()"><code class="function">gdk_pixbuf_save_to_buffer()</code></a> 以获取更多信息。
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>一个 <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td>
<td>接收这个新的缓冲区的指针的地址。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>buffer_size</code></em> :</span></p></td>
<td>接收这个新的缓冲区的大小的地址。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>文件的格式</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>option_keys</code></em> :</span></p></td>
<td>要设置的选项的名称，以 <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> 结束。</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>option_values</code></em> :</span></p></td>
<td>名字选项的值</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>return location for error, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>错误是否已经被设置</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-save-to-stream"></a><h3>gdk_pixbuf_save_to_stream ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            gdk_pixbuf_save_to_stream           (<em class="parameter"><code><a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>,
                                                         <em class="parameter"><code><a href="../gio/GOutputStream.html"><span class="type">GOutputStream</span></a> *stream</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
                                                         <em class="parameter"><code><a href="../gio/GCancellable.html"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Saves <em class="parameter"><code>pixbuf</code></em> to an output stream.
</p>
<p>
Supported file formats are currently "jpeg", "tiff", "png", "ico" or 
"bmp". See <a class="link" href="gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-buffer" title="gdk_pixbuf_save_to_buffer ()"><code class="function">gdk_pixbuf_save_to_buffer()</code></a> for more details.
</p>
<p>
The <em class="parameter"><code>cancellable</code></em> can be used to abort the operation from another 
thread. If the operation was cancelled, the error <code class="literal">GIO_ERROR_CANCELLED</code> 
will be returned. Other possible errors are in the <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GDK-PIXBUF-ERROR:CAPS" title="GDK_PIXBUF_ERROR"><span class="type">GDK_PIXBUF_ERROR</span></a> 
and <a href="../gio/gio-GIOError.html#G-IO-ERROR:CAPS"><code class="literal">G_IO_ERROR</code></a> domains. 
</p>
<p>
The stream is not closed.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>a <a class="link" href="gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
<td>a <a href="../gio/GOutputStream.html"><span class="type">GOutputStream</span></a> to save the pixbuf to</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>name of file format</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
<td>optional <a href="../gio/GCancellable.html"><span class="type">GCancellable</span></a> object, <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>return location for error, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>保存选项的键-值对(key-value)的列表(list)。</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the pixbuf was saved successfully, <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if an
error was set.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>